//
//  NSTimer+YBAdd.m
//  YBCategories
//
//  Created by yiban on 16/6/14.
//  Copyright © 2016年 lcb. All rights reserved.
//
#import "NSTimer+YBAdd.h"
#import "YBCategoriesMacro.h"

YBSYNTH_DUMMY_CLASS(NSTimer_YBAdd)


@implementation NSTimer (YBAdd)

+ (void)_YB_ExecBlock:(NSTimer *)timer {
    if ([timer userInfo]) {
        void (^block)(NSTimer *timer) = (void (^)(NSTimer *timer))[timer userInfo];
        block(timer);
    }
}

+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)seconds block:(void (^)(NSTimer *timer))block repeats:(BOOL)repeats {
    return [NSTimer scheduledTimerWithTimeInterval:seconds target:self selector:@selector(_YB_ExecBlock:) userInfo:[block copy] repeats:repeats];
}

+ (NSTimer *)timerWithTimeInterval:(NSTimeInterval)seconds block:(void (^)(NSTimer *timer))block repeats:(BOOL)repeats {
    return [NSTimer timerWithTimeInterval:seconds target:self selector:@selector(_YB_ExecBlock:) userInfo:[block copy] repeats:repeats];
}

@end
